import { RouteRecordRaw } from "vue-router";
import HomeView from "@/views/general/HomeView.vue";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AdminView from "@/views/general/AdminView.vue";
import NoAuthView from "@/views/general/NoAuthView.vue";
import CompetitionDetails from "@/views/competition/CompetitionDetails.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import QuestionsView from "@/views/question/QuestionsView.vue";
import QuestionSubmitView from "@/views/question/QuestionSubmitView.vue";
import ViewQuestionView from "@/views/question/ViewQuestionView.vue";
import CompetitionView from "@/views/competition/CompetitionView.vue";
import AddCompetitionView from "@/views/competition/AddCompetitionView.vue";
import JudgeInfoView from "@/views/question/JudgeInfoView.vue";
import AddQuestionAnswerView from "@/views/question/AddQuestionAnswerView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
    ],
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/",
    name: "题目列表",
    component: QuestionsView,
  },
  {
    path: "/competition",
    name: "竞赛列表",
    component: CompetitionView,
  },
  {
    path: "/questions",
    name: "浏览题目",
    component: QuestionsView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/question_submit",
    name: "浏览题目提交",
    component: QuestionSubmitView,
  },
  {
    path: "/view/question/:id",
    name: "在线做题",
    component: ViewQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/add/question/",
    name: "创建题目",
    component: AddQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true,
    },
  },
  {
    path: "/update/question/:id",
    name: "更新题目",
    component: AddQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true,
    },
  },
  {
    path: "/competition/details/:id",
    name: "竞赛详情",
    component: CompetitionDetails,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/add/competition",
    name: "新增竞赛",
    component: AddCompetitionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true,
    },
  },
  {
    path: "/update/competition/:id",
    name: "修改竞赛",
    component: AddCompetitionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true,
    },
  },
  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuthView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/view/judgeInfo/:id",
    name: "提交详情",
    component: JudgeInfoView,
    props: true,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/create/answer/:id",
    name: "发布题解",
    component: AddQuestionAnswerView,
    props: true,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true,
    },
  },
  {
    path: "/update/answer/:id",
    name: "修改题解",
    component: AddQuestionAnswerView,
    props: true,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true,
    },
  },
];
